// component.h : contains the interface declaration for all component classes
//$Id: Component.h 21 2009-08-17 05:31:44Z brwarner2 $
#pragma once
#include "types.h"

//Make sure boost any casting is in effect
using boost::any_cast;

//Object manager class
class CObjectManager;

//Entity class
class CEntity;

//Area class
class CArea;

//Component interface
class IComponent
{
public:
	//Initialization function
	virtual void Init( const ParameterList& params ) {}

	//Deinitialization function
	virtual void Deinit( void ) {}

	//Returns the ID of the component
	virtual ComponentID GetComponentID( void ) = 0;

	//Messaging function for communication
	virtual void Message( MessageID message, const boost::any& arg = 0 ) {}

	//Gets the ID of the object this belongs to
	ObjectID GetObjectID( void ) { return m_objectID; }

	//Handler for GM function calls
	virtual int GMCall( gmThread*, const std::string& name ) { return GM_EXCEPTION; }

	//Gets the area the object is in
	CArea* GetArea(void) { return m_pArea; }

	//Gets the entity of the object
	CEntity* GetEntity(void) { return m_pEntity; }

	//Allow access by the object manager
	friend class CObjectManager;

protected:
	//Gets the owning object manager
	CObjectManager* GetObjectManager( void ) { return m_pOManager; }

	//Gets the gmMachine
	gmMachine* GetMachine( void ) { return m_pGM; }

private:
	//Object ID
	ObjectID m_objectID;

	//Entity helper
	CEntity* m_pEntity;

	//Object manager
	CObjectManager* m_pOManager;

	//Gamemonkey machine
	gmMachine* m_pGM;

	//Area the component is inside
	CArea* m_pArea;
};